{extend name="base/base" /}
{block name="style"}
<style type="text/css">
.layui-table-cell{
     height: auto!important;
     white-space: normal;
}
</style>
{/block}
{block name="content"}
<!-- <script type="text/html" id="switchTpl">
  <input type="checkbox" name="id" value="{{d.id}}" lay-skin="switch" lay-filter="button" lay-text="开|关" {{ d.val == 1 ? 'checked' : '' }}>
</script> -->
  <div class="layui-form-item layui-form-pane">
    <div class="layui-inline">
        <div class="demoTable">
          <!-- <button class="layui-btn layui-btn-normal" onclick="add()">新增</button> -->
        </div>
      </div>
  <table id="table" lay-filter="table"></table> 
</div>
  <!-- <script type="text/html" id="list">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="list">详细数据</a>
  </script> -->
   <script type="text/html" id="edit">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  </script>
{/block}
{block name="script"}
<script>
layui.use(['table', 'laydate','form'], function(){
  var table   = layui.table;
  var laydate = layui.laydate;
  var form    = layui.form;
  table.render({
    elem: '#table'
    ,height: 'full-150'
    ,url: '/admin/invest/inconfigList/' //数据接口
    ,limit:20
    ,page: true //开启分页
    ,id:'reload'
    ,cols: [[ //表头
        
         {field:'name', title: '名称', width: 200}
        ,{field:'min', title: '交易金额最低', width: 200}
        ,{field:'max', title: '交易金额最高', width: 200}
        ,{field:'days', title: '日交易次数', width: 200}
        ,{field:'rate', title: '日收益比例', width: 200}
        ,{field:'price', title: '价格', width: 200}
        ,{field:'total', title: '总数', width: 200}
        ,{field:'has', title: '已售', width: 200}
        // ,{field:'status', title: '状态', width: 200,templet: function(d){
        //  if (d.status == 1) {
        //     return '<span style="color:red">已开启</span>'
        //   }
        //   if (d.status == 0) {
        //     return '<span style="color:green">已关闭</span>'
        //   }
        // }}
        // ,{field:'开关', title: '开关', width: 200,templet: function(d){
        //  if (d.is_open == 1) {
        //     return '<span style="color:red">已开启</span>'
        //   }
        //   if (d.is_open == 0) {
        //     return '<span style="color:green">已关闭</span>'
        //   }
        // }}
        ,{title: '操作', toolbar: '#edit', width: 200}
        
    ]]
  }); 

    //编辑 删除
  table.on('tool(table)', function(obj){
    var data = obj.data;
    //编辑
    if(obj.event === 'edit'){
      layer.open({
        type: 2 ,
        title: '编辑',   //标题
        area: ['500px', '700px'],   //宽高
        shade: 0.4,   //遮罩透明度
        content: '/admin/invest/editConfig?id='+data.id,//支持获取DOM元素
        // end:function(){
        //   $(".layui-laypage-btn")[0].click();
        // }
        });
    }
  });
});
function add(){
  layer.open({
  type: 2,
  title: '新增',   //标题
  area: ['500px', '700px'],   //宽高
  shade: 0.4,   //遮罩透明度
  content: '/admin/invest/editConfig',//支持获取DOM元素
  // end:function(){
  //   $(".layui-laypage-btn")[0].click();
  // }
  });
}
</script>
{/block}
